home *** CD-ROM | disk | FTP | other *** search
/ Game.EXE 2001 January / Game.EXE_01_2001.iso / demos / Blade of Darkness / data1.cab / Program_Executable_Files / Lib / GenFX.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2000-11-16  |  31.7 KB  |  673 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 1.5)
  3.  
  4. import Bladex
  5. import AuxFuncs
  6. import whrandom
  7. import InitDataField
  8. import GameStateAux
  9. import Auras
  10. import Objects
  11. import CharStats
  12. import ObjStore
  13.  
  14. def LevelUpFX(EntityName, ColourGradation, AuraParams, AuraGradient, AuraVar1Args, AuraVar2Args, PSParams, LightIntensity, timer = 'Timer15', timespersec = 15, sound = ''):
  15.     ent = Bladex.GetEntity(EntityName)
  16.     if ColourGradation:
  17.         l = ent.Level
  18.         if ent.Level > 20:
  19.             r = 255
  20.             g = 255 * ((29.0 - l) / 8.0)
  21.             b = 0
  22.         elif ent.Level > 13:
  23.             r = 255 * ((l - 14.0) / 6.0)
  24.             g = 255
  25.             b = 0
  26.         elif ent.Level > 6:
  27.             r = 0
  28.             g = 255
  29.             b = 255 * ((13.0 - l) / 6.0)
  30.         else:
  31.             r = 0
  32.             g = 255 * (l / 6.0)
  33.             b = 255
  34.         AuraGradient = (AuraGradient[0], r / 255.0, g / 255.0, b / 255.0, AuraGradient[4], AuraGradient[5], r / 255.0, g / 255.0, b / 255.0, AuraGradient[9], AuraGradient[10])
  35.     else:
  36.         r = PSParams[3]
  37.         g = PSParams[4]
  38.         b = PSParams[5]
  39.     LevelUpParticleData = PSParams[0]
  40.     for i in range(PSParams[2]):
  41.         Bladex.SetParticleGVal(PSParams[1], i, r, g, b, LevelUpParticleData[2 * i], LevelUpParticleData[2 * i + 1])
  42.     
  43.     AuraName = EntityName + 'AuraLevelUp'
  44.     (a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2) = (AuraName, AuraVar2Args[0], AuraVar2Args[1], AuraVar2Args[2], AuraVar2Args[3], AuraVar2Args[4], 1, '', (), timer, timespersec)
  45.     (a1, b1, c1, d1, e1, f1, g1, h1, i1, j1, k1) = (AuraName, AuraVar1Args[0], AuraVar1Args[1], AuraVar1Args[2], AuraVar1Args[3], AuraVar1Args[4], 0, AuxFuncs.FadeAndScaleAura, (a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2), timer, timespersec)
  46.     alup = Bladex.CreateEntity(AuraName, 'Entity Aura', 0, 0, 0)
  47.     alup.SetAuraParams(AuraParams[0], AuraParams[1], AuraParams[2], AuraParams[3], AuraParams[4], AuraParams[5])
  48.     alup.SetAuraGradient(AuraGradient[0], AuraGradient[1], AuraGradient[2], AuraGradient[3], AuraGradient[4], AuraGradient[5], AuraGradient[6], AuraGradient[7], AuraGradient[8], AuraGradient[9], AuraGradient[10])
  49.     ent.Link(alup)
  50.     alup.SetAuraActive(1)
  51.     AuxFuncs.FadeAndScaleAura(a1, b1, c1, d1, e1, f1, g1, h1, i1, j1, k1)
  52.     PSName = EntityName + 'PSLevelUp'
  53.     pslup = Bladex.CreateEntity(PSName, 'Entity Particle System Dperson', 0, 0, 0)
  54.     pslup.PersonName = EntityName
  55.     pslup.ParticleType = PSParams[1]
  56.     pslup.PPS = PSParams[6]
  57.     pslup.YGravity = PSParams[7]
  58.     pslup.Friction = PSParams[8]
  59.     pslup.RandomVelocity = PSParams[9]
  60.     pslup.NormalVelocity = PSParams[10]
  61.     pslup.FollowFactor = PSParams[11]
  62.     pslup.Time2Live = PSParams[12]
  63.     pslup.Velocity = (0.0, 0.0, 0.0)
  64.     pslup.DeathTime = Bladex.GetTime() + PSParams[13]
  65.     LightName = EntityName + 'LightLevelUp'
  66.     llup = Bladex.CreateEntity(LightName, 'Entity Spot', 0, 0, 0)
  67.     llup.Color = (r, g, b)
  68.     llup.Intensity = 0.0
  69.     llup.Precission = 0.01
  70.     llup.CastShadows = 0
  71.     llup.Visible = 0
  72.     llup.Flick = 0
  73.     ent.Link(llup)
  74.     AuxFuncs.SpotIntensityVariation(LightName, 0.0, LightIntensity, f1 / 1.6, 0, 0.0, 0.0, timer, timespersec)
  75.     Bladex.AddScheduledFunc(Bladex.GetTime() + f1, AuxFuncs.SpotIntensityVariation, (LightName, LightIntensity, 0.0, f2 / 1.2, 1, 0.0, 0.0, timer, timespersec))
  76.  
  77.  
  78. def ChangeNodesElectricDischarge(person_name, ray_name, list_of_nodes, timespersec, endtime):
  79.     person = Bladex.GetEntity(person_name)
  80.     ray = Bladex.GetEntity(ray_name)
  81.     n1 = whrandom.randint(0, len(list_of_nodes) - 1)
  82.     n2 = whrandom.randint(0, len(list_of_nodes) - 1)
  83.     while n1 == n2:
  84.         n2 = whrandom.randint(0, len(list_of_nodes) - 1)
  85.     node1 = list_of_nodes[n1]
  86.     node2 = list_of_nodes[n2]
  87.     ray.Position = person.Rel2AbsPoint(0, 0, 0, node1)
  88.     ray.Target = person.Rel2AbsPoint(0, 0, 0, node2)
  89.     if Bladex.GetTime() > endtime:
  90.         Bladex.AddScheduledFunc(Bladex.GetTime() + 1.0 / timespersec, ray.SubscribeToList, ('Pin',))
  91.     else:
  92.         Bladex.AddScheduledFunc(Bladex.GetTime() + 1.0 / timespersec, ChangeNodesElectricDischarge, (person_name, ray_name, list_of_nodes, timespersec, endtime))
  93.  
  94.  
  95. def ElectricDischarge(person_name, ray_name, r, g, b, amplitude, list_of_nodes, timespersec, time):
  96.     person = Bladex.GetEntity(person_name)
  97.     ray = Bladex.CreateEntity(ray_name, 'Entity ElectricBolt', 0, 0, 0)
  98.     ray.Target = (0, 0, 0)
  99.     ray.FixedTarget = 0
  100.     ray.MaxAmplitude = amplitude
  101.     ray.MinSectorLength = 10000
  102.     ray.CoreGlowColor = (r, g, b)
  103.     ray.InnerGlowColor = (r / 2, g / 2, b / 2)
  104.     ray.OuterGlowColor = (0.0, 0.0, 0.0)
  105.     ray.Damage = 0
  106.     ray.Active = 1
  107.     n1 = whrandom.randint(0, len(list_of_nodes) - 1)
  108.     n2 = whrandom.randint(0, len(list_of_nodes) - 1)
  109.     while n1 == n2:
  110.         n2 = whrandom.randint(0, len(list_of_nodes) - 1)
  111.     node1 = list_of_nodes[n1]
  112.     node2 = list_of_nodes[n2]
  113.     ray.Position = person.Rel2AbsPoint(0, 0, 0, node1)
  114.     ray.Target = person.Rel2AbsPoint(0, 0, 0, node2)
  115.     endtime = Bladex.GetTime() + time
  116.     Bladex.AddScheduledFunc(Bladex.GetTime() + 1.0 / timespersec, ChangeNodesElectricDischarge, (person_name, ray_name, list_of_nodes, timespersec, endtime))
  117.  
  118.  
  119. class WeaponFX:
  120.     
  121.     def __init__(self, WeaponName, auraparams, auragradient, prtldata, lightdata):
  122.         self.ObjId = ObjStore.GetNewId()
  123.         ObjStore.ObjectsStore[self.ObjId] = self
  124.         weapon = Bladex.GetEntity(WeaponName)
  125.         self.WeaponName = WeaponName
  126.         self.Aura = None
  127.         self.Particles = None
  128.         self.Light = None
  129.         if auraparams:
  130.             (s, a, ci, f, b, am) = auraparams
  131.             (m, r1, g1, b1, a1, imd, r2, g2, b2, a2, emd) = auragradient
  132.             self.Aura = Bladex.CreateEntity(WeaponName + 'Aura', 'Entity Aura', 0, 0, 0)
  133.             self.Aura.SetAuraParams(s, a, ci, f, b, am)
  134.             self.Aura.SetAuraGradient(m, r1, g1, b1, a1, imd, r2, g2, b2, a2, emd)
  135.             weapon.Link(self.Aura)
  136.             self.Aura.SetAuraActive(1)
  137.         
  138.         if prtldata:
  139.             (pt, pps, v, nv, rv, g, fr, ff, t2l) = prtldata
  140.             self.Particles = Bladex.CreateEntity(WeaponName + 'Particles', 'Entity Particle System Dobj', 0, 0, 0)
  141.             self.Particles.ObjectName = WeaponName
  142.             self.Particles.ParticleType = pt
  143.             self.Particles.PPS = pps
  144.             self.Particles.Velocity = v
  145.             self.Particles.NormalVelocity = nv
  146.             self.Particles.RandomVelocity = rv
  147.             self.Particles.YGravity = g
  148.             self.Particles.Friction = fr
  149.             self.Particles.FollowFactor = ff
  150.             self.Particles.Time2Live = t2l
  151.         
  152.         if lightdata:
  153.             (i, color, fl) = lightdata
  154.             self.Light = Bladex.CreateEntity(WeaponName + 'Light', 'Entity Spot', 0, 0, 0)
  155.             self.Light.Intensity = i
  156.             self.Light.Color = color
  157.             self.Light.Flick = fl
  158.             self.Light.CastShadows = 0
  159.             self.Light.Visible = 0
  160.             weapon.Link(self.Light)
  161.         
  162.  
  163.     
  164.     def __del__(self):
  165.         del ObjStore.ObjectsStore[self.ObjId]
  166.  
  167.     
  168.     def persistent_id(self):
  169.         return self.ObjId
  170.  
  171.     
  172.     def __getstate__(self):
  173.         return (1, self.ObjId, self.WeaponName, GameStateAux.SaveEntityAux(self.Aura), GameStateAux.SaveEntityAux(self.Particles), GameStateAux.SaveEntityAux(self.Light))
  174.  
  175.     
  176.     def __setstate__(self, parm):
  177.         print 'GenFX.__setstate__()', parm
  178.         if parm[0] == 1:
  179.             self.ObjId = parm[1]
  180.             ObjStore.ObjectsStore[self.ObjId] = self
  181.             self.WeaponName = parm[2]
  182.             self.Aura = GameStateAux.LoadEntityAux(parm[3])
  183.             self.Particles = GameStateAux.LoadEntityAux(parm[4])
  184.             self.Light = GameStateAux.LoadEntityAux(parm[5])
  185.         else:
  186.             print 'WeaponFX.__setstate__() -> Version mismatch'
  187.             self.WeaponName = ''
  188.             self.Aura = ''
  189.             self.Particles = ''
  190.             self.Light = ''
  191.             self.ObjId = ObjStore.GetNewId()
  192.             ObjStore.ObjectsStore[self.ObjId] = self
  193.  
  194.  
  195.  
  196. def AddWeaponFX(WeaponName, data):
  197.     weapon = Bladex.GetEntity(WeaponName)
  198.     if not weapon:
  199.         print 'El arma especificada no existe!'
  200.         return None
  201.     
  202.     if not data:
  203.         InitDataField.Initialise(weapon)
  204.         data = weapon.Data
  205.     
  206.     if weapon.Kind in ('QueenSword', 'VampWeapon'):
  207.         auraparams = (80, 1, 1, 0, 0, 0)
  208.         auragradient = (2, 0.8, 0.1, 0.1, 0.2, 0.0, 0.4, 0.0, 0.0, 0.0, 0.6)
  209.         if weapon.Kind == 'VampWeapon':
  210.             prtldata = ('GotasSangre', 20, (0.0, 0.0, 0.0), 0.0, 0.0, 2000.0, 0.01, 0.0, 24)
  211.         else:
  212.             prtldata = ()
  213.         lightdata = ()
  214.     elif weapon.Kind in ('CrushHammer', 'DalWeapon', 'SteelFeather'):
  215.         auraparams = (80, 1, 1, 0, 0, 0)
  216.         auragradient = (2, 0.5, 0.6, 0.0, 0.2, 0.0, 0.2, 0.3, 0.0, 0.1, 0.5)
  217.         prtldata = ('GasVenenoso', 30, (0.0, 0.0, 0.0), 0.0, 1.0, 0.0, 0.02, 0.0, 60)
  218.         lightdata = ()
  219.     elif weapon.Kind in ('FireBigSword', 'FireAxe', 'FireSword', 'FireBo'):
  220.         auraparams = (40, 1, 1, 0, 0, 1)
  221.         auragradient = (2, 0.8, 0.6, 0.0, 0.6, 0.0, 0.8, 0.1, 0.0, 0.0, 0.6)
  222.         prtldata = ('Llamita', 400, (0.0, 0.0, 0.0), 1.0, 0.0, -1000.0, 0.02, 0.0, 10)
  223.         lightdata = (1.0, (255, 120, 0), 1)
  224.         weapon.SelfIlum = 0.8
  225.     elif weapon.Kind in ('IceAxe', 'IceHammer', 'IceSword', 'TaiSword'):
  226.         auraparams = (10, 1, 1, 0, 0, 1)
  227.         auragradient = (2, 0.9, 1.0, 1.0, 0.2, 0.1, 0.4, 0.8, 1.0, 0.2, 1.0)
  228.         prtldata = ('Vaho', 20, (0.0, 0.0, 0.0), 0.0, 1.0, 150.0, 0.02, 0.0, 60)
  229.         lightdata = ()
  230.         weapon.SelfIlum = 0.2
  231.         weapon.Alpha = 0.99
  232.         weapon.RasterMode = 'AdditiveAlpha'
  233.     elif weapon.Kind in ('BladeSword2', 'BladeSword2Barbarian'):
  234.         auraparams = (80, 1, 1, 0, 0, 1)
  235.         auragradient = (2, 0.8, 0.9, 1.0, 0.6, 0.0, 0.3, 0.4, 0.9, 0.0, 0.6)
  236.         prtldata = ('BrillosBladeSword', 15, (0.0, 0.0, 0.0), 0.0, 0.0, 0.0, 0.01, 0.0, 6)
  237.         lightdata = (1.0, (235, 245, 255), 0)
  238.         weapon.SelfIlum = 0.8
  239.     else:
  240.         print 'No hay efecto definido para este tipo de arma!'
  241.         return None
  242.     data.WeaponFX = WeaponFX(WeaponName, auraparams, auragradient, prtldata, lightdata)
  243.  
  244.  
  245. class PersonItemFX:
  246.     
  247.     def __init__(self, PersonName, ItemName, TimeEffect):
  248.         pers = Bladex.GetEntity(PersonName)
  249.         item = Bladex.GetEntity(ItemName)
  250.         time = Bladex.GetTime()
  251.         self.PersonName = PersonName
  252.         self.ItemName = ItemName
  253.         AuraParams0 = (240, 0.01, 1.0, 0, 1, 1)
  254.         AuraParams1 = (50, 1.0, 1.0, 0, 1, 1)
  255.         AuraParams2 = (40, 0.6, 1.0, 0, 1, 1)
  256.         XtraParam0 = ('Bladex.GetEntity("' + PersonName + '").SelfIlum', 0.0)
  257.         XtraParam1 = ('Bladex.GetEntity("' + PersonName + '").SelfIlum', 0.6)
  258.         XtraParam2 = ('Bladex.GetEntity("' + PersonName + '").SelfIlum', 0.1)
  259.         if item.Kind == 'PowerPotion':
  260.             AuraGradient0 = (2, 0.2, 0.4, 0.8, 1.0, 0.2, 0.0, 0.2, 0.8, 0.0, 0.7)
  261.             AuraGradient1 = (2, 0.8, 0.9, 1.0, 1.0, 0.2, 0.0, 0.2, 0.9, 0.1, 1.0)
  262.             self.Aura = Auras.MakeAura(PersonName, TimeEffect, AuraParams0, (), (), AuraGradient0, 1, XtraParam0)
  263.             self.Aura.Data.AddEvent(time + 1.0, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  264.             self.Aura.Data.AddEvent(time + TimeEffect - 4.1, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  265.             self.Aura.Data.AddEvent(time + TimeEffect - 3.6, AuraParams2, (), (), AuraGradient1, 1, XtraParam2)
  266.             self.Aura.Data.AddEvent(time + TimeEffect - 3.1, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  267.             self.Aura.Data.AddEvent(time + TimeEffect - 2.7, AuraParams2, (), (), AuraGradient1, 1, XtraParam2)
  268.             self.Aura.Data.AddEvent(time + TimeEffect - 2.3, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  269.             self.Aura.Data.AddEvent(time + TimeEffect - 2.0, AuraParams2, (), (), AuraGradient1, 1, XtraParam2)
  270.             self.Aura.Data.AddEvent(time + TimeEffect - 1.7, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  271.             self.Aura.Data.AddEvent(time + TimeEffect - 1.5, AuraParams2, (), (), AuraGradient1, 1, XtraParam2)
  272.             self.Aura.Data.AddEvent(time + TimeEffect - 1.3, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  273.             self.Aura.Data.AddEvent(time + TimeEffect - 1.2, AuraParams2, (), (), AuraGradient1, 1, XtraParam2)
  274.             self.Aura.Data.AddEvent(time + TimeEffect - 1.1, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  275.             self.Aura.Data.AddEvent(time + TimeEffect - 1.05, AuraParams2, (), (), AuraGradient1, 1, XtraParam2)
  276.             self.Aura.Data.AddEvent(time + TimeEffect - 1.0, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  277.             self.Aura.Data.AddEvent(time + TimeEffect, AuraParams0, (), (), AuraGradient0, 1, XtraParam0)
  278.         elif item.Kind == 'Brazalete':
  279.             AuraGradient0 = (2, 0.8, 0.6, 0.0, 1.0, 0.2, 0.4, 0.3, 0.0, 0.0, 0.7)
  280.             AuraGradient1 = (2, 1.0, 0.9, 0.5, 1.0, 0.1, 0.4, 0.3, 0.0, 0.0, 1.0)
  281.             self.Aura = Auras.MakeAura(PersonName, TimeEffect, AuraParams0, (), (), AuraGradient0, 1, XtraParam0)
  282.             self.Aura.Data.AddEvent(time + 1.0, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  283.             self.Aura.Data.AddEvent(time + TimeEffect - 4.1, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  284.             self.Aura.Data.AddEvent(time + TimeEffect - 3.6, AuraParams2, (), (), AuraGradient1, 1, XtraParam2)
  285.             self.Aura.Data.AddEvent(time + TimeEffect - 3.1, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  286.             self.Aura.Data.AddEvent(time + TimeEffect - 2.7, AuraParams2, (), (), AuraGradient1, 1, XtraParam2)
  287.             self.Aura.Data.AddEvent(time + TimeEffect - 2.3, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  288.             self.Aura.Data.AddEvent(time + TimeEffect - 2.0, AuraParams2, (), (), AuraGradient1, 1, XtraParam2)
  289.             self.Aura.Data.AddEvent(time + TimeEffect - 1.7, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  290.             self.Aura.Data.AddEvent(time + TimeEffect - 1.5, AuraParams2, (), (), AuraGradient1, 1, XtraParam2)
  291.             self.Aura.Data.AddEvent(time + TimeEffect - 1.3, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  292.             self.Aura.Data.AddEvent(time + TimeEffect - 1.2, AuraParams2, (), (), AuraGradient1, 1, XtraParam2)
  293.             self.Aura.Data.AddEvent(time + TimeEffect - 1.1, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  294.             self.Aura.Data.AddEvent(time + TimeEffect - 1.05, AuraParams2, (), (), AuraGradient1, 1, XtraParam2)
  295.             self.Aura.Data.AddEvent(time + TimeEffect - 1.0, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  296.             self.Aura.Data.AddEvent(time + TimeEffect, AuraParams0, (), (), AuraGradient0, 1, XtraParam0)
  297.         elif item.Kind == 'Corona':
  298.             AuraGradient0 = (2, 1.0, 0.4, 0.0, 1.0, 0.2, 1.0, 0.0, 0.0, 0.0, 0.7)
  299.             AuraGradient1 = (2, 1.0, 0.7, 0.0, 1.0, 0.1, 1.0, 0.0, 0.0, 0.0, 1.0)
  300.             self.Aura = Auras.MakeAura(PersonName, TimeEffect, AuraParams0, (), (), AuraGradient0, 1, XtraParam0)
  301.             self.Aura.Data.AddEvent(time + 1.0, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  302.             self.Aura.Data.AddEvent(time + TimeEffect - 4.1, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  303.             self.Aura.Data.AddEvent(time + TimeEffect - 3.6, AuraParams2, (), (), AuraGradient1, 1, XtraParam2)
  304.             self.Aura.Data.AddEvent(time + TimeEffect - 3.1, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  305.             self.Aura.Data.AddEvent(time + TimeEffect - 2.7, AuraParams2, (), (), AuraGradient1, 1, XtraParam2)
  306.             self.Aura.Data.AddEvent(time + TimeEffect - 2.3, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  307.             self.Aura.Data.AddEvent(time + TimeEffect - 2.0, AuraParams2, (), (), AuraGradient1, 1, XtraParam2)
  308.             self.Aura.Data.AddEvent(time + TimeEffect - 1.7, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  309.             self.Aura.Data.AddEvent(time + TimeEffect - 1.5, AuraParams2, (), (), AuraGradient1, 1, XtraParam2)
  310.             self.Aura.Data.AddEvent(time + TimeEffect - 1.3, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  311.             self.Aura.Data.AddEvent(time + TimeEffect - 1.2, AuraParams2, (), (), AuraGradient1, 1, XtraParam2)
  312.             self.Aura.Data.AddEvent(time + TimeEffect - 1.1, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  313.             self.Aura.Data.AddEvent(time + TimeEffect - 1.05, AuraParams2, (), (), AuraGradient1, 1, XtraParam2)
  314.             self.Aura.Data.AddEvent(time + TimeEffect - 1.0, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  315.             self.Aura.Data.AddEvent(time + TimeEffect, AuraParams0, (), (), AuraGradient0, 1, XtraParam0)
  316.         else:
  317.             AuraGradient0 = (2, 0.0, 1.0, 0.4, 1.0, 0.2, 0.0, 0.8, 0.0, 0.0, 0.7)
  318.             AuraGradient1 = (2, 0.0, 1.0, 0.7, 1.0, 0.1, 0.0, 0.6, 0.0, 0.0, 1.0)
  319.             self.Aura = Auras.MakeAura(PersonName, TimeEffect, AuraParams0, (), (), AuraGradient0, 1, XtraParam0)
  320.             self.Aura.Data.AddEvent(time + 1.0, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  321.             self.Aura.Data.AddEvent(time + TimeEffect - 4.1, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  322.             self.Aura.Data.AddEvent(time + TimeEffect - 3.6, AuraParams2, (), (), AuraGradient1, 1, XtraParam2)
  323.             self.Aura.Data.AddEvent(time + TimeEffect - 3.1, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  324.             self.Aura.Data.AddEvent(time + TimeEffect - 2.7, AuraParams2, (), (), AuraGradient1, 1, XtraParam2)
  325.             self.Aura.Data.AddEvent(time + TimeEffect - 2.3, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  326.             self.Aura.Data.AddEvent(time + TimeEffect - 2.0, AuraParams2, (), (), AuraGradient1, 1, XtraParam2)
  327.             self.Aura.Data.AddEvent(time + TimeEffect - 1.7, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  328.             self.Aura.Data.AddEvent(time + TimeEffect - 1.5, AuraParams2, (), (), AuraGradient1, 1, XtraParam2)
  329.             self.Aura.Data.AddEvent(time + TimeEffect - 1.3, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  330.             self.Aura.Data.AddEvent(time + TimeEffect - 1.2, AuraParams2, (), (), AuraGradient1, 1, XtraParam2)
  331.             self.Aura.Data.AddEvent(time + TimeEffect - 1.1, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  332.             self.Aura.Data.AddEvent(time + TimeEffect - 1.05, AuraParams2, (), (), AuraGradient1, 1, XtraParam2)
  333.             self.Aura.Data.AddEvent(time + TimeEffect - 1.0, AuraParams1, (), (), AuraGradient1, 1, XtraParam1)
  334.             self.Aura.Data.AddEvent(time + TimeEffect, AuraParams0, (), (), AuraGradient0, 1, XtraParam0)
  335.  
  336.     
  337.     def __getstate__(self):
  338.         return (1, self.PersonName, self.ItemName, GameStateAux.SaveEntityAux(self.Aura))
  339.  
  340.     
  341.     def __setstate__(self, parm):
  342.         if parm[0] == 1:
  343.             self.PersonName = parm[1]
  344.             self.ItemName = parm[2]
  345.             self.Aura = GameStateAux.LoadEntityAux(parm[3])
  346.         else:
  347.             print 'ItemFX.__setstate__() -> Version mismatch'
  348.             self.PersonName = ''
  349.             self.ItemName = ''
  350.             self.Aura = ''
  351.  
  352.  
  353.  
  354. def AddPersonItemFX(PersonName, ItemName, TimeEffect):
  355.     pers = Bladex.GetEntity(PersonName)
  356.     item = Bladex.GetEntity(ItemName)
  357.     if not item or item.Kind not in ('PowerPotion', 'Amuletofantasma', 'Brazalete', 'Corona'):
  358.         print 'El item especificado no existe no hay efecto definido para este tipo de item!'
  359.         return None
  360.     
  361.     pers.Data.PersonItemFX = PersonItemFX(PersonName, ItemName, TimeEffect)
  362.  
  363.  
  364. def ChangeRasterMode(ent_name, mode):
  365.     Bladex.GetEntity(ent_name).RasterMode = mode
  366.  
  367.  
  368. def PersonMagicallyAppearing():
  369.     TimeEffect = 2.0
  370.     time = Bladex.GetTime()
  371.     char = Bladex.GetEntity('Player1')
  372.     char.Alpha = 0.01
  373.     char.RasterMode = 'Read'
  374.     Bladex.AddScheduledFunc(time + TimeEffect, ChangeRasterMode, ('Player1', 'Full'))
  375.     AuxFuncs.FadeObject('Player1', 0.01, 1.0, 2.0)
  376.     if char.InvLeft != '':
  377.         obj = Bladex.GetEntity(char.InvLeft)
  378.         obj.RasterMode = 'Read'
  379.         Bladex.AddScheduledFunc(time + TimeEffect, ChangeRasterMode, (char.InvLeft, 'Full'))
  380.         AuxFuncs.FadeObject(char.InvLeft, 0.01, obj.Alpha, TimeEffect)
  381.     
  382.     if char.InvRight != '':
  383.         obj = Bladex.GetEntity(char.InvRight)
  384.         obj.RasterMode = 'Read'
  385.         Bladex.AddScheduledFunc(time + TimeEffect, ChangeRasterMode, (char.InvRight, 'Full'))
  386.         AuxFuncs.FadeObject(char.InvRight, 0.01, obj.Alpha, TimeEffect)
  387.     
  388.     if char.InvLeftBack != '':
  389.         obj = Bladex.GetEntity(char.InvLeftBack)
  390.         obj.RasterMode = 'Read'
  391.         Bladex.AddScheduledFunc(time + TimeEffect, ChangeRasterMode, (char.InvLeftBack, 'Full'))
  392.         AuxFuncs.FadeObject(char.InvLeftBack, 0.01, obj.Alpha, TimeEffect)
  393.     
  394.     if char.InvRightBack != '':
  395.         obj = Bladex.GetEntity(char.InvRightBack)
  396.         obj.RasterMode = 'Read'
  397.         Bladex.AddScheduledFunc(time + TimeEffect, ChangeRasterMode, (char.InvRightBack, 'Full'))
  398.         AuxFuncs.FadeObject(char.InvRightBack, 0.01, obj.Alpha, TimeEffect)
  399.     
  400.     AuraParams0 = (240, 0.01, 1.0, 0, 1, 1)
  401.     AuraParams1 = (50, 1.0, 1.0, 0, 1, 1)
  402.     AuraParams2 = (50, 0.01, 1.0, 0, 1, 1)
  403.     AuraGradient0 = (2, 0.2, 0.4, 0.8, 1.0, 0.2, 0.0, 0.2, 0.8, 0.0, 0.7)
  404.     AuraGradient1 = (2, 0.8, 0.9, 1.0, 1.0, 0.2, 0.0, 0.2, 0.9, 0.1, 1.0)
  405.     aura = Auras.MakeAura('Player1', TimeEffect, AuraParams0, (), (), AuraGradient0)
  406.     aura.Data.AddEvent(time + TimeEffect / 2.0, AuraParams1, (), (), AuraGradient1)
  407.     aura.Data.AddEvent(time + TimeEffect, AuraParams2, (), (), AuraGradient0)
  408.     ps = Bladex.CreateEntity('PSPersonMagicallyAppearing', 'Entity Particle System Dperson', 0.0, 0.0, 0.0)
  409.     ps.PersonName = 'Player1'
  410.     ps.ParticleType = 'FastEnergyConc'
  411.     ps.PPS = 200
  412.     ps.YGravity = 0.0
  413.     ps.Friction = 0.0
  414.     ps.Velocity = (0.0, 0.0, 0.0)
  415.     ps.RandomVelocity = 0.5
  416.     ps.NormalVelocity = -2.0
  417.     ps.Time2Live = 30
  418.     ps.DeathTime = time + TimeEffect / 2.0
  419.  
  420.  
  421. def PersonMagicallyDisappearing():
  422.     TimeEffect = 2.0
  423.     time = Bladex.GetTime()
  424.     char = Bladex.GetEntity('Player1')
  425.     char.Alpha = 1.0
  426.     char.RasterMode = 'Read'
  427.     AuxFuncs.FadeObject('Player1', 1.0, 0.01, TimeEffect)
  428.     if char.InvLeft != '':
  429.         obj = Bladex.GetEntity(char.InvLeft)
  430.         obj.RasterMode = 'Read'
  431.         AuxFuncs.FadeObject(char.InvLeft, obj.Alpha, 0.01, TimeEffect)
  432.     
  433.     if char.InvRight != '':
  434.         obj = Bladex.GetEntity(char.InvRight)
  435.         obj.RasterMode = 'Read'
  436.         AuxFuncs.FadeObject(char.InvRight, obj.Alpha, 0.01, TimeEffect)
  437.     
  438.     if char.InvLeftBack != '':
  439.         obj = Bladex.GetEntity(char.InvLeftBack)
  440.         obj.RasterMode = 'Read'
  441.         AuxFuncs.FadeObject(char.InvLeftBack, obj.Alpha, 0.01, TimeEffect)
  442.     
  443.     if char.InvRightBack != '':
  444.         obj = Bladex.GetEntity(char.InvRightBack)
  445.         obj.RasterMode = 'Read'
  446.         AuxFuncs.FadeObject(char.InvRightBack, obj.Alpha, 0.01, TimeEffect)
  447.     
  448.     AuraParams0 = (240, 0.01, 1.0, 0, 1, 1)
  449.     AuraParams1 = (50, 1.0, 1.0, 0, 1, 1)
  450.     AuraParams2 = (50, 0.01, 1.0, 0, 1, 1)
  451.     AuraGradient0 = (2, 0.2, 0.4, 0.8, 1.0, 0.2, 0.0, 0.2, 0.8, 0.0, 0.7)
  452.     AuraGradient1 = (2, 0.8, 0.9, 1.0, 1.0, 0.2, 0.0, 0.2, 0.9, 0.1, 1.0)
  453.     aura = Auras.MakeAura('Player1', TimeEffect, AuraParams2, (), (), AuraGradient0)
  454.     aura.Data.AddEvent(time + TimeEffect / 2.0, AuraParams1, (), (), AuraGradient1)
  455.     aura.Data.AddEvent(time + TimeEffect, AuraParams0, (), (), AuraGradient0)
  456.     ps = Bladex.CreateEntity('PSPersonMagicallyAppearing', 'Entity Particle System Dperson', 0.0, 0.0, 0.0)
  457.     ps.PersonName = 'Player1'
  458.     ps.ParticleType = 'EnergyDissip'
  459.     ps.PPS = 200
  460.     ps.YGravity = 0.0
  461.     ps.Friction = 0.0
  462.     ps.Velocity = (0.0, 0.0, 0.0)
  463.     ps.RandomVelocity = 0.5
  464.     ps.NormalVelocity = 2.0
  465.     ps.Time2Live = 60
  466.     ps.DeathTime = time + TimeEffect / 3.0
  467.  
  468.  
  469. class MagicTransport:
  470.     
  471.     def __init__(self, trsector_name, magictr_position):
  472.         self.Position = (x, y, z) = magictr_position
  473.         self.TrSectorMax = trsector_name
  474.         self.TrSectorMin = trsector_name + '_In'
  475.         self.MagicCilinder = Bladex.CreateEntity(trsector_name + '_Cil', 'CilindroTransportador', x, y, z)
  476.         self.MagicCilinder.Orientation = (0.707107, 0.707107, 0.0, 0.0)
  477.         self.MagicCilinder.Scale = 0.1
  478.         self.MagicCilinder.Alpha = 0.0
  479.         self.MagicCilinder.CastShadows = 0
  480.         self.AGE_Number = 0
  481.         Bladex.AddTriggerSector(trsector_name + '_In', 'Transportadores', y + 1150.0, y - 1150.0, [
  482.             (x + 500.0, z + 500.0),
  483.             (x - 500.0, z + 500.0),
  484.             (x - 500.0, z - 500.0),
  485.             (x + 500.0, z - 500.0)])
  486.         Bladex.SetTriggerSectorFunc(trsector_name + '_In', 'OnEnter', self.UseMagicTransport)
  487.         Bladex.SetTriggerSectorFunc(trsector_name, 'OnEnter', self.OpenMagicTransport)
  488.         Bladex.SetTriggerSectorFunc(trsector_name, 'OnLeave', self.CloseMagicTransport)
  489.         self.ObjId = ObjStore.GetNewId()
  490.         ObjStore.ObjectsStore[self.ObjId] = self
  491.  
  492.     
  493.     def persistent_id(self):
  494.         return self.ObjId
  495.  
  496.     
  497.     def __getstate__(self):
  498.         return (1, self.ObjId, self.Position, self.TrSectorMax, self.TrSectorMin, self.AGE_Number, GameStateAux.SaveEntityAux(self.MagicCilinder))
  499.  
  500.     
  501.     def __setstate__(self, parm):
  502.         if parm[0] == 1:
  503.             self.ObjId = parm[1]
  504.             ObjStore.ObjectsStore[self.ObjId] = self
  505.             self.Position = parm[2]
  506.             self.TrSectorMax = parm[3]
  507.             self.TrSectorMin = parm[4]
  508.             self.AGE_Number = parm[5]
  509.             self.MagicCilinder = GameStateAux.LoadEntityAux(parm[6])
  510.         else:
  511.             print 'MagicTransport.__setstate__() -> Version mismatch'
  512.             self.ObjId = ObjStore.GetNewId()
  513.             ObjStore.ObjectsStore[self.ObjId] = self
  514.             self.Position = ''
  515.             self.TrSectorMax = ''
  516.             self.TrSectorMin = ''
  517.             self.AGE_Number = ''
  518.             self.MagicCilinder = ''
  519.  
  520.     
  521.     def RotateMagicCilinderGrad(self, obj_name, time):
  522.         self.MagicCilinder.RotateRel(0, 0, 0, 0, 0, 1, 0.08)
  523.  
  524.     
  525.     def RotateMagicCilinder(self):
  526.         self.MagicCilinder.TimerFunc = self.RotateMagicCilinderGrad
  527.         self.MagicCilinder.SubscribeToList('Timer30')
  528.  
  529.     
  530.     def OpenMagicTransport(self, trsector, ent_name):
  531.         import GameText
  532.         AuxFuncs.ScaleObjectV2(self.MagicCilinder.Name, self.MagicCilinder.Scale, 1.0, -1, 2.0, self.RotateMagicCilinderGrad, (0, 0), self.RotateMagicCilinder, (), 0)
  533.         self.AGE_Number = self.AGE_Number + 1
  534.         openps = Bladex.CreateEntity(self.MagicCilinder.Name + '_PS_' + `self.AGE_Number`, 'Entity Particle System Dobj', 0.0, 0.0, 0.0)
  535.         openps.ObjectName = self.MagicCilinder.Name
  536.         openps.ParticleType = 'LittleEnergyDissip'
  537.         openps.PPS = 600
  538.         openps.YGravity = 0.0
  539.         openps.Friction = 0.0
  540.         openps.Velocity = (0.0, 0.0, 0.0)
  541.         openps.RandomVelocity = 0.0
  542.         openps.NormalVelocity = 0.0
  543.         openps.Time2Live = 30
  544.         GameText.ShowMessage('Entra en el transportador para abandonar el mapa')
  545.  
  546.     
  547.     def CloseMagicTransport(self, trsector, ent_name):
  548.         import GameText
  549.         openps = Bladex.GetEntity(self.MagicCilinder.Name + '_PS_' + `self.AGE_Number`)
  550.         if openps:
  551.             openps.DeathTime = Bladex.GetTime() + 2.0
  552.             AuxFuncs.ScaleObjectV2(self.MagicCilinder.Name, self.MagicCilinder.Scale, 0.1, 1, 2.0, self.RotateMagicCilinderGrad, (0, 0), '', (), 0)
  553.             GameText.HideMessage()
  554.         
  555.  
  556.     
  557.     def UseMagicTransport(self, trsector, ent_name):
  558.         import GotoMapVars
  559.         import Scorer
  560.         Bladex.RemoveTriggerSectorFunc(trsector, 'OnEnter')
  561.         Bladex.DeactivateInput()
  562.         Scorer.SetVisible(0)
  563.         PersonMagicallyDisappearing()
  564.         self.CloseMagicTransport(0, 0)
  565.         Bladex.AddScheduledFunc(Bladex.GetTime() + 2.0, AuxFuncs.FadeTo, (2.0, 2.0))
  566.         Bladex.AddScheduledFunc(Bladex.GetTime() + 4.0, GotoMapVars.EndOfLevel, ())
  567.  
  568.  
  569.  
  570. def CreateMagicTransport(trsector_name, magictr_position):
  571.     magictr = MagicTransport(trsector_name, magictr_position)
  572.     return magictr
  573.  
  574.  
  575. class LightFX:
  576.     
  577.     def __init__(self):
  578.         self.Entity = 'Player1'
  579.         self.TurnOnTime = 1.0
  580.         self.TurnOffTime = 1.0
  581.         self.QuickTurnOffTime = 0.5
  582.         self.MaxIntensity = 2.0
  583.         self.TimeMaxIntensity = 2.0
  584.         self.Color = (255, 255, 255)
  585.         self.Flick = 0
  586.  
  587.  
  588.  
  589. def AddParticles(entity_source_name, prtl_type, pps, rnd_vel, normal_vel, friction, time2live, death_time):
  590.     ent_src = Bladex.GetEntity(entity_source_name)
  591.     if not ent_src:
  592.         print 'La entidad especificada como fuente de las particulas no existe!!!'
  593.         return None
  594.     
  595.     id_number = int(10.0 * Bladex.GetTime())
  596.     if ent_src.Person:
  597.         prtl_sys = Bladex.CreateEntity(entity_source_name + 'prtlsys' + `id_number`, 'Entity Particle System Dperson', 0, 0, 0)
  598.         prtl_sys.PersonName = entity_source_name
  599.     else:
  600.         prtl_sys = Bladex.CreateEntity(entity_source_name + 'prtlsys' + `id_number`, 'Entity Particle System Dobj', 0, 0, 0)
  601.         prtl_sys.ObjectName = entity_source_name
  602.     prtl_sys.ParticleType = prtl_type
  603.     prtl_sys.Time2Live = time2live
  604.     prtl_sys.PPS = pps
  605.     prtl_sys.NormalVelocity = normal_vel
  606.     prtl_sys.RandomVelocity = rnd_vel
  607.     prtl_sys.Friction = friction
  608.     prtl_sys.YGravity = 0
  609.     prtl_sys.Velocity = (0, 0, 0)
  610.     if death_time:
  611.         prtl_sys.DeathTime = Bladex.GetTime() + death_time
  612.     
  613.     return prtl_sys
  614.  
  615.  
  616. def ModifyParticles(prtl_sys, new_pps, new_rnd_vel, new_normal_vel, new_friction, new_time2live, new_death_time):
  617.     prtl_sys.Time2Live = new_time2live
  618.     prtl_sys.PPS = new_pps
  619.     prtl_sys.NormalVelocity = new_normal_vel
  620.     prtl_sys.RandomVelocity = new_rnd_vel
  621.     prtl_sys.Friction = new_friction
  622.     if new_death_time:
  623.         prtl_sys.DeathTime = Bladex.GetTime() + new_death_time
  624.     
  625.  
  626.  
  627. def PlaySoundFX(sound, entity_source_name, volume, pitch):
  628.     ent_src = Bladex.GetEntity(entity_source_name)
  629.     if not ent_src:
  630.         print 'La entidad especificada como fuente del sonido no existe!!!'
  631.         return None
  632.     
  633.     sound.Volume = volume
  634.     sound.Pitch = pitch
  635.     sound.Position = ent_src.Position
  636.     sound.PlaySound(0)
  637.  
  638.  
  639. def InflictDamageFX(VictimName, aura_size_var = 250.0, aura_exp_time = 0.7, r = 10, g = 50, b = 240, light_intensity = 0.0, sound = None, volume = 1.0, pitch = 1.0):
  640.     victim = Bladex.GetEntity(VictimName)
  641.     (x, y, z) = victim.Position
  642.     ar = r / 255.0
  643.     ag = g / 255.0
  644.     ab = b / 255.0
  645.     r1 = ar + (1.0 - ar) / 1.5
  646.     g1 = ag + (1.0 - ag) / 1.5
  647.     b1 = ab + (1.0 - ab) / 1.5
  648.     dif = min(ar, ag, ab)
  649.     r2 = ar - dif
  650.     g2 = ag - dif
  651.     b2 = ab - dif
  652.     time = Bladex.GetTime()
  653.     aura = Auras.MakeAura(VictimName, aura_exp_time, (1, 0.01, 1.0, 0, 0, 1), (), (), (2, r1, g1, b1, 0.6, 0.3, ar, ag, ab, 0.4, 1.0))
  654.     aura.Data.AddEvent(time + aura_exp_time / 4.0, (2.0 * aura_size_var / 3.0, 1.0, 1.0, 0, 0, 1), (), (), (2, r1, g1, b1, 0.6, 0.3, ar, ag, ab, 0.4, 1.0))
  655.     aura.Data.AddEvent(time + aura_exp_time, (aura_size_var, 0.01, 1.0, 0, 0, 1), (), (), (2, ar, ag, ab, 0.6, 0.4, r2, g2, b2, 0.4, 0.5))
  656.     if light_intensity:
  657.         id_number = int(10.0 * Bladex.GetTime())
  658.         limp = Bladex.CreateEntity(VictimName + 'ImpactLight' + `id_number`, 'Entity Spot', x, y, z)
  659.         limp.Color = (r, g, b)
  660.         limp.Intensity = light_intensity
  661.         limp.Precission = 0.01
  662.         limp.CastShadows = 0
  663.         limp.Visible = 0
  664.         limp.Flick = 0
  665.         AuxFuncs.SpotIntensityVariation(limp.Name, light_intensity, 0.0, aura_exp_time, 1, 0.0, 0.0, 'Timer30', 30)
  666.     
  667.     if sound:
  668.         sound.Volume = volume
  669.         sound.Pitch = pitch
  670.         sound.Play(x, y, z, 0)
  671.     
  672.  
  673.